#!/bin/sh

#
# android_arm64-v8a_manaager 任务:
# 1 定义android的arm64-v8a有关的变量:
# host,arch,arm64-v8a的交叉编译工具位置.
# 2 如果有必要合并各个arch的库
#

# +++ Description Start +++
# 编译sdl2+ffmpeg
# 整体编译时间
# === Description End ===

# +++ 变量声明 Start+++
export g_arch="arm64"

# 当前脚本的架构目录
export g_scriptArchDir=${g_scriptPlatformDir}/${g_arch}
# 当前Build的架构目录
export g_buildArchDir=${g_buildPlatformDir}/${g_arch}
# 输出目录
export g_outputArchDir=${g_outputPlatformDir}/${g_arch}

# 环境变量
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"



# host,cc,cxx是必须指定正确的.
export g_arch="arm64"
export g_host="aarch64-ios-darwin"
# C Compiler,通过xcrun -sdk,同时设置了其他交叉编译工具.
vendor="apple"
export g_cc="xcrun -sdk iphoneos clang -target ${g_arch}-${vendor}-ios${g_minSdkVersion}"
# 用g_cflags作为全局的,具体的CFLAGS给各个库自己单独使用
export g_cflags="-target ${g_arch}-${vendor}-ios${g_minSdkVersion}"
export CXX="xcrun -sdk iphoneos clang -target ${g_arch}-${vendor}-ios${g_minSdkVersion}"
main () {
    export PKG_CONFIG_PATH=""
    g_compileAction=`yq .x264 ./config.yml`
    . ${g_scriptArchDir}/${g_platform}_${g_arch}_x264.sh
    . ${SCRITP_ROOT_DIR}/common/CommonBuildLib.sh 
    export PKG_CONFIG_PATH=$g_outputArchDir/x264/lib/pkgconfig

    g_compileAction=`eval "yq .sdl2 $g_configFile"`
    . ${g_scriptArchDir}/${g_platform}_${g_arch}_sdl2-2.0.10-ugc.sh
    . ${SCRITP_ROOT_DIR}/common/CommonBuildLib.sh 
    PKG_CONFIG_PATH+=:$g_outputArchDir/sdl2-2.0.10-ugc/lib/pkgconfig
    
    g_compileAction=`eval "yq .ffmpeg $g_configFile"`
    . ${g_scriptArchDir}/${g_platform}_${g_arch}_ffmpeg-4.2-ugc.sh
    . ${SCRITP_ROOT_DIR}/common/CommonBuildLib.sh 

    g_compileAction=`eval "yq .ffmpeg-cli-wrapper $g_configFile"`
    . ${g_scriptArchDir}/${g_platform}_${g_arch}_ffmpeg-cli-wrapper.sh
    . ${SCRITP_ROOT_DIR}/common/CommonBuildLib.sh 

    g_compileAction=`eval "yq .ffmpeg-cli-wrapper-framework $g_configFile"`
    . ${g_scriptArchDir}/${g_platform}_${g_arch}_ffmpeg-cli-wrapper-framework.sh
    . ${SCRITP_ROOT_DIR}/common/CommonBuildLib.sh 

    exit
    . ${g_scriptArchDir}/${g_platform}_${g_arch}_lame-3.100.sh $COMPILE_ACTION_CONFIGURE_MAKE
    . ${SCRITP_ROOT_DIR}/common/CommonBuildLib.sh 
}

main





